# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: mark.blakeney at bullet-systems dot net

_pipname=debugpy
pkgname=python-$_pipname
pkgver=1.6.7
pkgrel=2
pkgdesc='An implementation of the Debug Adapter Protocol for Python'
arch=(loong64 x86_64)
url='https://aka.ms/debugpy'
license=(EPL MIT)
depends=(python)
makedepends=(python-setuptools)
source=(https://github.com/microsoft/debugpy/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('77c6e071dad4df8147a5f54a1dc3d8f70f7711984d44f6774b6348accd91485d')

prepare() {
  cd $_pipname-$pkgver
# remove precompiled libs
  rm src/debugpy/_vendored/pydevd/pydevd_attach_to_process/*.{so,dll,dylib,exe,pdb}
}

build() {
  cd $_pipname-$pkgver
  python setup.py build
# Compile attach libraries
  cd build/lib*/debugpy/_vendored/pydevd/pydevd_attach_to_process
  g++ ${CXXFLAGS} -shared -o attach_linux_amd64.so -fPIC -nostartfiles linux_and_mac/attach.cpp ${LDFLAGS}
}

package() {
  cd $_pipname-$pkgver
  python setup.py install --skip-build --root="$pkgdir" --optimize=1

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
